{include file="public/head"/}
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">店铺信息</div>
                <div class="layui-card-body" pad15>
                    <div class="layui-form" wid100 lay-filter="">

                        <div class="layui-form-item">
                            <label class="layui-form-label">用户昵称</label>
                            <div class="layui-input-inline">
                                <input type="text" name="username" lay-verify="required"
                                       value="{$info.username|default=''}" placeholder="" autocomplete="off"
                                       class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">真实姓名</label>
                            <div class="layui-input-inline">
                                <input type="text" name="realname" lay-verify="required"
                                       value="{$info.realname|default=''}" placeholder="" autocomplete="off"
                                       class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">手机号码</label>
                            <div class="layui-input-inline">
                                <input type="text" name="mobile" lay-verify="required" value="{$info.mobile|default=''}"
                                       placeholder="" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">生日</label>
                            <div class="layui-input-inline">
                                <input type="text" name="birthday" lay-verify="required" value="{$info.birthday|default=''}"
                                       placeholder="" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">余额</label>
                            <div class="layui-input-inline">
                                <input type="text" name="money" lay-verify="required" value="{$info.money|default=''}"
                                       placeholder="" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">积分</label>
                            <div class="layui-input-inline">
                                <input type="text" name="integral" lay-verify="required"
                                       value="{$info.integral|default=''}" placeholder="" autocomplete="off"
                                       class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">用户头像</label>
                            <div class="layui-input-inline">
                                <input name="photo" id="photo" value="{$info.photo|default=''}" placeholder="图片地址"
                                       class="layui-input">
                            </div>
                            <div class="layui-input-inline layui-btn-container" style="width: auto;">
                                <button type="button" class="layui-btn" id="thumbUpload">
                                    <i class="layui-icon">&#xe67c;</i>上传图片
                                </button>
                                <button class="layui-btn layui-btn-primary" layadmin-event="logoShow">查看图片</button>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">登录密码</label>
                            <div class="layui-input-inline">
                                <input type="password" name="password" placeholder="请输入密码" class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">
                                密码必须大于6位，小于15位
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <input type="hidden" value="{$info.user_id|default=''}" name="user_id">
                                <button class="layui-btn" lay-submit lay-filter="edit-but">确认保存</button>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/foot"/}
<script>
    layui.config({
        base: '__LAYDMIN__/', {if config('app.app_debug')}version: true{/if}
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form', 'upload'], function () {
        var $ = layui.$, admin = layui.admin, table = layui.table, element = layui.element, form = layui.form,
            util = layui.util, upload = layui.upload;
        var uri = "{if isset($user_id)}{:url(SYS_PATH.'/'.CONTROLLER.'/edit')}{else}{:url(SYS_PATH.'/'.CONTROLLER.'/add')}{/if}";
        form.on('submit(edit-but)', function (data) {
            admin.req({
                url: uri,
                type: 'post',
                data: data.field,
                success: function (res) {
                    if (res.code == 0) {
                        window.top.layer.msg(res.msg, {icon: 1, time: 1000,shade:[0.5,'#000000']}, function () {
                            layer.closeAll("iframe");
                            //刷新父页面
                            parent.location.reload();
                        });
                    } else {
                        window.top.layer.msg(res.msg, {icon: 2, time: 1000,shade:[0.5,'#000']});
                        return;
                    }
                }
            });
        });


        //上传logo
        var thumb = $('#photo');
        upload.render({
            url: '{:url(SYS_PATH."/uploads/upimg")}'
            , elem: '#thumbUpload'
            , done: function (res) {
                if (res.code == 0) {
                    thumb.val(res.url);
                    //logo.parent().append('<input type="hidden" name="logo_aid" value="'+res.aid+'">')
                } else {
                    layer.msg(res.msg, {icon: 5});
                }
            }
        });
        //查看logo
        admin.events.logoShow = function (othis) {
            var src = thumb.val();
            layer.photos({
                photos: {
                    "title": "查看图片" //相册标题
                    , "data": [{
                        "src": src //原图地址
                    }]
                }
                , shade: 0.01
                , closeBtn: 1
                , anim: 5
            });
        };

        //地区联动
        form.on('select(province)', function (data) {
            var pid = data.value;
            var loading = layer.load(1, {shade: [0.1, '#fff']});
            $.get("{:url(SYS_PATH.'/'.CONTROLLER.'/getRegion')}?pid=" + pid, function (data) {
                layer.close(loading);
                var html = '<option value="">请选择市</option>';
                $.each(data, function (i, value) {
                    html += '<option value="' + value.id + '">' + value.name + '</option>';
                });
                $('#city').html(html);
                $('#area').html('<option value="">请选择县/区</option>');
                form.render()
            });
        });
        form.on('select(city)', function (data) {
            var pid = data.value;
            var loading = layer.load(1, {shade: [0.1, '#fff']});
            $.get("{:url(SYS_PATH.'/'.CONTROLLER.'/getRegion')}?pid=" + pid, function (data) {
                layer.close(loading);
                var html = '<option value="">请选择县/区</option>';
                $.each(data, function (i, value) {
                    html += '<option value="' + value.id + '">' + value.name + '</option>';
                });
                $('#area').html(html);

                form.render()
            });
        });

    });
</script>
</body>
</html>